
<template>
	<view>
		<view class="search">
			<view class="icon-cl">
				<image class="icon" src="/static/myorder/search.png" />
			</view>
			<input class="text" v-model="query" @input="search" placeholder="输入关键字搜索" />
		</view>

		<view class="results">
			<view v-for="(item, index) in filteredResults" :key="index" class="result-item">{{ item.title }}</view>
		</view>
	</view>
</template>

<script>

	export default {
		name: "Search",
		data() {
			return {
				userdata: {
					openId: '',
					token: ''
				},
			}
		},
		methods: {
			
			async getActivities() {
				// 获取用户输入的查询字符串
				const query = this.query.trim().toLowerCase();
				
				if (!query) {
					this.results = [];
					return;
				}
				
				await this.$myRequest({
					url: '/organizer/getActivities',
					method: 'GET',
					header: {
						Authorization: this.userdata.token,
						'content-type': 'application/x-www-form-urlencoded',
					},
					data: {
						name: query,
						size: 10,
						current: 1
					},
				}).then(res => {
					console.log(res, 'getActivities')
					let data = res.data.data
					let activityInfo = data.filter((item) => item.activityName == this.activityName)
					console.log(activityInfo, 'activityInfo')
					
				}).catch(err => {
					console.log(err)
				})
			
			},
			async getStorage() {
				const openId = uni.getStorageSync('openId')
				const token = uni.getStorageSync('token')
				this.userdata.openId = openId
				this.userdata.token = token
			},
			
		},
		onReady(options) {
			console.log(options)
		},
		onLoad(options) {
			this.getStorage()
			this.getActivities()
		},
	};
</script>


<style>
	/* 搜索框样式 */

	.search {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		margin-left: 3%;
		width: 94%;
		height: 60rpx;
		background-color: whitesmoke;
		margin-top: 5%;
		border: 1rpx solid whitesmoke;
		border-radius: 20rpx;
	}

	/* 搜索框提示文字样式 */
	.search input {
		font-size: 27rpx;
		font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
		padding-left: 30rpx;
	}

	/* 搜索框小图标 */
	.search image {
		width: 40rpx;
		height: 40rpx;
		padding-right: 20rpx;
	}
</style>